package ptij.vocoder.baseModel.lp_analysis;

import ptolemy.actor.*;
import ptolemy.kernel.*;
import ptolemy.kernel.util.*;
import ptolemy.data.ObjectToken;
import ptolemy.data.BooleanToken;
import ptolemy.data.type.*;

import ptij.vocoder.baseModel.*;

//////////////////////////////////////////////////////////////////////////
//// Q_plsf_5
/**

@author Ivan Jeukens
@version v 0.1 07/08/2003
*/
public class Q_plsf_5 extends TypedAtomicActor {

    public Q_plsf_5(CompositeEntity container, String name) throws
            IllegalActionException, NameDuplicationException {
        super(container, name);

        lsp1 = new TypedIOPort(this, "lsp1", true, false);
        lsp1.setTypeEquals(BaseType.OBJECT);

        lsp2 = new TypedIOPort(this, "lsp2", true, false);
        lsp2.setTypeEquals(BaseType.OBJECT);

        txdtx_ctrl = new TypedIOPort(this, "txdtx_ctrl", true, false);
        txdtx_ctrl.setTypeEquals(BaseType.OBJECT);

        reset_flag = new TypedIOPort(this, "reset_flag", true, false); 
        reset_flag.setTypeEquals(BaseType.BOOLEAN);

        lsp1_q = new TypedIOPort(this, "lps1_q", false, true);
        lsp1_q.setTypeEquals(BaseType.OBJECT);

        lsp2_q = new TypedIOPort(this, "lsp2_q", false, true);
        lsp2_q.setTypeEquals(BaseType.OBJECT);

        indice = new TypedIOPort(this, "indice", false, true);
        indice.setTypeEquals(BaseType.OBJECT);
    }

    ///////////////////////////////////////////////////////////////////
    ////                     ports and parameters                  ////

    // Input ports
    public TypedIOPort lsp1;
    public TypedIOPort lsp2;
    public TypedIOPort txdtx_ctrl;
    public TypedIOPort reset_flag;

    // Output Ports
    public TypedIOPort lsp1_q;
    public TypedIOPort lsp2_q;
    public TypedIOPort indice;

    ///////////////////////////////////////////////////////////////////
    ////                         public methods                    ////

    public void initialize() throws IllegalActionException {
        super.initialize();
    }
    
    public void fire() throws IllegalActionException {
       if(reset_flag.hasToken(0)) {
           BooleanToken bt = (BooleanToken) reset_flag.get(0);
           _init();
       }
        
       ObjectToken obj = (ObjectToken) lsp1.get(0);
       Short [] arg1 = (Short []) obj.getValue();
       
       obj = (ObjectToken) lsp2.get(0);
       Short [] arg2 = (Short []) obj.getValue();
       
       Short [] arg3 = new Short[Cnst.M];
       Short [] arg4 = new Short[Cnst.M];
       Short [] arg5 = new Short[Cnst.PRM_SIZE];
       
       obj = (ObjectToken) txdtx_ctrl.get(0);
       Short arg6 = (Short) obj.getValue();

       _q_plsf_5(arg1, arg2, arg3, arg4, arg5, arg6);

       obj = new ObjectToken(arg3);
       lsp1_q.broadcast(obj);
       
       obj = new ObjectToken(arg4);
       lsp2_q.broadcast(obj);
       
       obj = new ObjectToken(arg5);
       indice.broadcast(obj);
    }

    ///////////////////////////////////////////////////////////////////
    ////                         private methods                   ////

    private void _q_plsf_5(Short [] lsp1, Short [] lsp2, Short [] lsp1_q,
            Short [] lsp2_q, Short [] indice, Short txdtx_ctrl) {

    }

    private void _init() {

    }
    
    ///////////////////////////////////////////////////////////////////
    ////                         private variables                 ////

}

